/*
 * Copyright (c) 2010, VeRSI Consortium
 *   (Victorian eResearch Strategic Initiative, Australia)
 * All rights reserved.
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the VeRSI, the VeRSI Consortium members, nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
package versi.vitro.oaiserviceprovider.service.handle.helper;

import versi.vitro.oaiserviceprovider.service.handle.api.HandleService;

/**
 * {@link HandleService} Helper.
 */
public interface HandleHelper {

    /**
     * Creation of a handle and adds a value to the created handle.
     * 
     * @param resourceType
     *            Either Description or URL.
     * @param resourceValue
     *            The new value.
     * @return String handle identifier that has been created.
     * */
    String pidCreateHandle(final String resourceType, final String resourceValue);

    /**
     * Creation of a handle and adds a value to the created handle.
     * 
     * @param resourceType
     *            Either Description or URL.
     * @param resourceValue
     *            The new value.
     * @param index
     *            The index of the value to be created.
     * @return String handle identifier that has been created.
     * */
    String pidCreateHandle(final String resourceType, final String resourceValue, final int index);

    /**
     * Adds a value associated with an existing handle.
     * 
     * @param handle
     *            The handle from which a value is to be added.
     * @param resourceType
     *            Either Description or URL.
     * @param resourceValue
     *            The new value.
     * @return String handle identifier that a value has been added.
     * */
    String pidAddValue(final String handle, final String resourceType, final String resourceValue);

    /**
     * Adds a value associated with an existing handle.
     * 
     * @param handle
     *            The handle from which a value is to be added.
     * @param resourceType
     *            Either Description or URL.
     * @param resourceValue
     *            The new value.
     * @param index
     *            The index of the value to be added.
     *@return String handle identifier that a value has been added.
     * */
    String pidAddValue(final String handle, final String resourceType, final String resourceValue, final int index);

    /**
     * Modifies the value and resource type associated with an existing handle.
     * 
     * @param handle
     *            The handle from which a value is to be modified.
     * @param index
     *            The index of the value to be modified.
     * @param resourceValue
     *            The new value.
     * @return boolean true if successful modify a handle value, false
     *         otherwise.
     */
    boolean pidModifyHandle(final String handle, final int index, final String resourceValue);

    /**
     * Deletes a value associated with an existing handle.
     * 
     * @param handle
     *            The handle from which a value is to be deleted.
     * @param index
     *            The index of the value to be deleted.
     * @return boolean true if successful delete a handle value, false
     *         otherwise.
     * */
    boolean pidDeleteValueByIndex(final String handle, final int index);

    /**
     * Returns a list of handles owned by the requestor, an owner being a
     * combination of identifier and authDomain passed in the body of the
     * request.
     * 
     * @return String[] A list of handle owned by the requestor.
     */
    String[] pidListHandle();

    /**
     * Sets ANDS service Application Id.
     * 
     * @param serviceAppId
     */
    void setServiceAppId(final String serviceAppId);

    /**
     * Sets ANDS service URL.
     * 
     * @param andServiceURL
     */
    void setAndServiceURL(final String andServiceURL);

    /**
     * Sets ANDS service identifier.
     * 
     * @param identifier
     */
    void setIdentifier(final String identifier);

    /**
     * Sets ANDS service authDomain.
     * 
     * @param authDomain
     */
    void setAuthDomain(final String authDomain);

    /**
     * Extracts the handle value from a response.
     * 
     * @param response
     * @return extract handle identifier from the ANDS web services response.
     */
    String extractHandleFromResponse(final String response);

}